package com.course.android.activity.ac;

import android.content.Intent;
import android.view.View;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baselib.android.utils.Logger;
import com.baselib.android.utils.ToastTool;
import com.course.android.R;
import com.course.android.activity.base.BaseNetActivity;
import com.course.controller.TestController;
import com.course.model.HttpConfigBean;

import java.util.List;

public class HttpActivity extends BaseNetActivity {

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected int bindLayout() {
        return R.layout.activity_http;
    }

    @Override
    protected void onActivityResultCallBack(Integer reqCode, Intent data) {

    }


    public void onClick(View view) {
        if (view.getId() == R.id.bt) {
            //普通请求
            TestController.getInstance().test("HttpActivity", this);
        }
        if (view.getId() == R.id.bt1) {
            //页面请求
            TestController.getInstance().testPage(this);
        }
    }

    @Override
    public <TestResp> void onData(HttpConfigBean flag, TestResp o) {
        Logger.e(JSONObject.toJSONString(o));
        ToastTool.show(this, JSON.toJSONString(o));
    }

    @Override
    public <String> void onPageData(HttpConfigBean flag, int pageNum, int pageSize, int total, List<String> array) {
        Logger.e("pageNum" + pageNum);
        Logger.e("pageSize" + pageSize);
        Logger.e("total" + total);
        Logger.e("array" + JSONArray.toJSONString(array));
        ToastTool.show(this, JSONArray.toJSONString(array));
    }
}
